home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / cm / cmtassoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-06  |  2.0 KB  |  46 lines

  1. // CmTAssoc.h
  2. // -----------------------------------------------------------------
  3. // Compendium - C++ Container Class Library
  4. // Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved
  5. // -----------------------------------------------------------------
  6. // Association template definition.
  7. // -----------------------------------------------------------------
  8.  
  9. #ifndef _CMTASSOC_H
  10. #define _CMTASSOC_H
  11.  
  12. #include <cm/include/cmdefs.h>
  13.  
  14. template <class T, class O> class CmTAssociation {   // Assoc definition.
  15. public:
  16.   CmTAssociation() {}                                // Default constructor.
  17.   CmTAssociation(const T&, const O&);                // Construct w/ key&object.
  18.   CmTAssociation(const T&);                          // Construct with key.
  19.   CmTAssociation(const CmTAssociation<T,O>&);        // Copy constructor.
  20.  
  21.   CmTAssociation<T,O>& operator=(const CmTAssociation<T,O>&); // Assignment.
  22.  
  23.   void     set   (const T&, const O&);               // Set new key and object.
  24.   const T& key   () const;                           // Return key value.
  25.   void     key   (const T&);                         // Set new key value.
  26.   const O& object() const;                           // Return object value.
  27.   void     object(const O&);                         // Set new object value.
  28.  
  29.   Bool operator==(const CmTAssociation<T,O>&) const; // Equality check.
  30.   Bool operator!=(const CmTAssociation<T,O>&) const; // In-equality check.
  31.   Bool operator< (const CmTAssociation<T,O>&) const; // Less than check.
  32.   Bool operator> (const CmTAssociation<T,O>&) const; // Greater than check.
  33.   Bool operator<=(const CmTAssociation<T,O>&) const; // Less than or equal.
  34.   Bool operator>=(const CmTAssociation<T,O>&) const; // Greater or equal.
  35.  
  36. protected:
  37.   T _key;                                            // Key value.
  38.   O _object;                                         // Object value.
  39. };
  40.  
  41. #if defined(__TURBOC__) || defined(__xlC__)
  42. #include <cm/include/cmtassoc.cc>
  43. #endif
  44.  
  45. #endif
  46.